struct ListNode
{
    int val;
    ListNode *next;
    ListNode()
        : val(0), next(nullptr) {}
    ListNode(int _val)
        : val(_val), next(nullptr) {}
    ListNode(int _val, ListNode *_next) : val(_val), next(_next) {}
};


class Solution {
public:
    //查找链表的中间节点
    ListNode* middleNode(ListNode* head) {
        ListNode* slow = head,*fast = head;
        while(fast && fast->next)
        {
            slow = slow->next;
            fast = fast->next->next;
        }
        return slow;
    }

    //删除链表的中间节点，该中间节点不是真正意义的中间节点
    void deleteNode(ListNode* node) {
        
        ListNode* tmp = node->next;
        node->val = tmp->val;
        node->next = tmp->next;
    }
};